﻿using Nest;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;

namespace ElasticSearchRealize.Model
{
    public class UserIndex : IDocumentIndexIdentity
    {
        /// <summary>
        /// 主键id
        /// TODO：根据雪花算法得出Id
        /// </summary>
        public long Id { get; set; }

        /// <summary>
        /// 主键id
        /// </summary>
        public string UserName { get; set; }

        /// <summary>
        /// 电话
        /// </summary>
        public string Phone { get; set; }

        /// <summary>
        /// 邮箱
        /// </summary>
        [Text(Analyzer = "ik_max_word",SearchAnalyzer ="",Norms = true)]
        public string Email { get; set; }


        /// <summary>
        /// 年齡
        /// </summary>
        public int Age { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateDateTime { get; set; }


        public string GetIndexDocumentId()
        {
            return $"{Id}";
        }

        public string GetIndexName()
        {
            return $"AUserIndex-{CreateDateTime.ToString("yyMM")}".ToLower();
        }

        public static string GetIndexNameByDate(DateTime dataTime) 
        {
            return $"AUserIndex-{dataTime.ToString("yyMM")}".ToLower();
        }
    }
}
